<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0,
		maximum-scale=1.0, user-scalable=no" />
		<title>设备设置</title>
		<link rel="stylesheet" type="text/css" href="css/app.css" />
		<script src="js/jquery.min.js"></script>
		<script src="js/vue.min.js"></script>
	</head>
	<body>
		<div class="jiantou">
			设备设置
		</div>
		<div id="cmm9801">
			<form class="main_text">
				<table align="center">
					<tr>
						<th>设备属性</th>
						<th>发送端</th>
					</tr>
					<tr>
						<td>端口1延时:</td>
						<td><input type="number" v-model="device.port1_delay" value=0></td>
					</tr>
					<tr>
						<td>端口2延时:</td>
						<td><input type="number" v-model="device.port2_delay" value=0></td>
					</tr>
					<tr>
						<td>端口3延时:</td>
						<td><input type="number" v-model="device.port3_delay" value=0></td>
					</tr>
					<tr>
						<td>端口4延时:</td>
						<td><input type="number" v-model="device.port4_delay" value=0></td>
					</tr>
					<tr>
						<td>端口5延时:</td>
						<td><input type="number" v-model="device.port5_delay" value=0></td>
					</tr>
					<tr>
						<td>衰减数:</td>
						<td><input type="number" v-model="device.attenuation" value=0></td>
					</tr>
				</table>
			</form>
			<p></p>
			<div>
				<a href="javascript:;" id="btn_ok" @click="save">
					确定
				</a>
				&nbsp;
				<a href="main.html">
					返回
				</a>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		var vm = new Vue({
			el: "#cmm9801",
			data: {
				device: {
					port1_delay: 0,
					port2_delay: 0,
					port3_delay: 0,
					port4_delay: 0,
					port5_delay: 0,
					attenuation: 0
				}
			},
			methods: {
				save: function(event) {
					$.ajax({
						type: "POST",
						url: "sbsz_set.action",
						data: vm.device,
						dataType: 'json',
						success: function(result) {
							if (result.login == "false") {
								sessionStorage.setItem('isLogin', 'false');
								parent.location = 'index.html';
								return;
							}
							if (result.success == 'true') {
								alert('success');
							} else {
								alert('failure');
							}
						}
					});
				},
				load: function(event) {
					$.ajax({
						url: 'cgi-bin/cmm9801.cgi',
						dataType: 'json',
						data: {
							optype: "sbsz_load"
						},
						success: function(result) {
							if (result.login == 'false') {
								sessionStorage.setItem('isLogin', 'false');
								parent.location = 'index.html';
								return;
							}
							vm.device = result;
						}
					});
				}
			},
			created: function() {
				//检查是否登陆
				var isLogin = sessionStorage.getItem("isLogin");
				if (isLogin != 'true') {
					window.location.href = "index.html";
					return;
				}
				//没有加载接口，暂时关闭。
				//this.load();
			}
		});
	</script>
</html>
